/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.smarttmt.suite.web.beans;

import com.smarttmt.suite.web.model.User;

/**
 *
 * @author Nicolás Rubén Caballero Ortega (ingeniero.desarrollo004@smarttmt.com
 * - helaman58@gmail.com)
 */
@javax.inject.Named(value = "userLoginBean")
@javax.enterprise.context.SessionScoped
public class UserLogin extends SmartSuiteBackingBean implements java.io.Serializable {

    private boolean isAuthenticated;
    private com.smarttmt.suite.web.model.User user;

    public boolean isIsAuthenticated() {
        return isAuthenticated;
    }

    @javax.annotation.PostConstruct
    public void initUserLogin() {
        user = new User();
    }

    public String authenticate() throws Exception {
        if(validateUser(user.getSessionUser())){
                setIsAuthenticated(true);
                return com.smarttmt.suite.web.domain.Constants.CUSTOMEROPERATIONS;
        }
        else return null;

    }

    public void setIsAuthenticated(boolean isAuthenticated) {
        this.isAuthenticated = isAuthenticated;
    }

    public com.smarttmt.suite.web.model.User getUser() {
        return user;
    }

    public void setUser(com.smarttmt.suite.web.model.User user) {
        this.user = user;
    }

}
